<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件委托</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        ul{
            height: 400px;
            width: 400px;
            background-color: aqua;
            list-style: none;
            display: flex;
           
        }
        li{
            height: 100px;
            width: 100px;
            background-color: antiquewhite;
            text-align: center;
            line-height: 100px;
            margin: 10px;        
        }
    </style>
</head>
<body>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
    </ul>
    <script>
        // 事件委托
        //1.获取到ul元素
        var ul=document.querySelector('ul')
        //2.给ul绑定点击事件
        ul.onclick=function(e){
            // console.log('点击事件触发')
            // console.log(e.target)
            //3.通过事件目标来判断你点击的是li
            //tagName标签名
            if(e.target.tagName==='LI'){
                console.log('你点击的是li')
            }
        }
    </script>
</body>
</html>